#pragma once
#include <qcolor.h>
#include <qvector3d.h>
#include <qvector2d.h>
#include <qtransform.h>
#include <qmap.h>
#include <qlist.h>
#include <qlistwidget.h>
#include <qstring.h>

#define RESOLUTION 256
#define PI 3.1415926
#define DEG2RAD 0.0174532
#define vec QVector3D
#define vec2 QVector2D

#ifndef DRAND48_H
#define DRAND48_H
#define drand48m 0x100000000LL  
#define drand48c 0xB16  
#define drand48a 0x5DEECE66DLL  
extern unsigned long long seed;
float drand48(void);
void srand48(unsigned int i);
#endif

QColor vec2color(vec value);
vec color2vec(QColor value);
vec max(const vec& v1, const vec& v2);

float clamp(const float& f0, const float& omin, const float& omax);
float clamp01(const float& f);

vec randvec();

class Ray
{
public:
	vec org, dir;
	Ray(vec org = vec(0, 0, 0), vec dir = vec(0, 0, 0)) :org(org), dir(dir.normalized()) {}
	vec rich(const float& t)const
	{
		return org + dir * t;
	}
};

class texture;
class material;

class hitInfo
{
public:
	float t;
	vec pos, normal;
	material* himat;
	hitInfo(material* himat, float t = INFINITY, vec pos = vec(0, 0, 0), vec normal = vec(0, 1, 0)) :
		t(t), pos(pos), normal(normal.normalized()), himat(himat) {}
};

class scatterInfo
{
public:
	Ray outRay;
	vec mult;

	scatterInfo(Ray outRay = Ray(), vec mult = vec(1, 1, 1)) :
		outRay(outRay), mult(mult) {}
};
